#include "unp.h"
#include "sum.h"

void str_cli(FILE *fp, int fd)
{
    char sendline[MAXLINE];
    struct args arg;
    struct result res;

    while (Fgets(sendline, MAXLINE, fp) != NULL) {
        if ( sscanf(sendline, "%ld %ld", &arg.arg1, &arg.arg2) != 2) {
            printf("input error\n");
            continue;
        }
        Writen(fd, &arg, sizeof(arg));
        if (Readn(fd, &res, sizeof(res)) == 0) {
            err_quit("str_cli: server terminated");
        }
        printf("%ld\n", res.sum);
    }
}

